package com.sds.sweng.swat.miplatform.ui.design.parts.area.sub;

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;

import com.sds.sweng.swat.miplatform.ui.design.layouts.FlowLayoutEx;
import com.sds.sweng.swat.miplatform.ui.design.models.area.sub.SubArea;
import com.sds.sweng.swat.miplatform.ui.design.parts.MiplatformDesignPart;

public class TabContentsSubAreaPart extends SubAreaPart {

	private Label figure;

	protected IFigure createFigure() {
		figure = (Label) super.createFigure();

		FlowLayoutEx layout = new FlowLayoutEx(false);
		figure.setLayoutManager(layout);

		drawChildren(figure);

		return figure;
	}

	private void drawChildren(Label parent) {
		if (getChildren().size() == 0) {
			resizeFigure(SubArea.MODEL_HEIGHT);
		} else {
			((MiplatformDesignPart) getChildren().get(0)).resizeFigure();
		}
	}

	protected void refreshVisuals() {
		drawChildren(figure);
	}

	public void resizeFigure(int height) {
		figure.setSize(getAreaWidth(), height);
	}

	@Override
	protected void createEditPolicies() {

	}

}
